package com.itheima.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.domain.OmsOrderOperateHistory;
import com.itheima.mapper.OmsOrderOperateHistoryMapper;
import com.itheima.service.OmsOrderOperateHistoryService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * <p>
 * 订单操作历史记录 服务实现类
 * </p>
 *
 * @author zhuguo
 * @since 2022-11-10
 */
@DubboService
public class OmsOrderOperateHistoryServiceImpl extends ServiceImpl<OmsOrderOperateHistoryMapper, OmsOrderOperateHistory> implements OmsOrderOperateHistoryService {
    @Autowired
    OmsOrderOperateHistoryMapper omsOrderOperateHistoryMapper;

    @Override
    public List<OmsOrderOperateHistory> findOperateHistory(Long orderId) {
        QueryWrapper<OmsOrderOperateHistory> qw = new QueryWrapper<>();
        qw.eq("order_id", orderId);
        return omsOrderOperateHistoryMapper.selectList(qw);
    }

    @Override
    public void save(List<OmsOrderOperateHistory> historyList) {
        for (OmsOrderOperateHistory history : historyList) {
            omsOrderOperateHistoryMapper.insert(history);
        }
    }

    @Override
    public Integer saveOne(OmsOrderOperateHistory history) {
        return omsOrderOperateHistoryMapper.insert(history);
    }
}
